import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
import app from './modules/app'
import settings from './modules/settings'
import user from './modules/user'

Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    userInfo: JSON.parse(window.localStorage.getItem('userInfo'))
  },
  modules: {
    app,
    settings,
    user
  },
  getters,
  mutations: {
    updateUserInfo(state, userInfo) {
      state.userInfo = userInfo
    },
    getUserInfo() {
      // eslint-disable-next-line no-undef
      return state.userInfo
    }
  }
})

export default store
